package com.yuwj.chinaa.activity;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yuwj.chinaa.R;
import com.yuwj.chinaa.base.BaseActivity;
import com.yuwj.chinaa.util.SharedpreferenceUtil;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 账户安全认证界面
 */
public class AccountSafetyCertificateActivity extends BaseActivity {


    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_phone_number)
    TextView tvPhoneNumber;
    @BindView(R.id.ll_phone_number)
    LinearLayout llPhoneNumber;
    @BindView(R.id.tv_email)
    TextView tvEmail;
    @BindView(R.id.ll_email)
    LinearLayout llEmail;

    public static Intent createIntent(Context context) {
        return new Intent(context, AccountSafetyCertificateActivity.class);
    }

    @Override
    public int setCustomContentViewResourceId() {
        return R.layout.activity_account_safety_certificate;
    }

    @Override
    protected void onResume() {
        super.onResume();
        entityUser = SharedpreferenceUtil.getInstance().getUserInfo(context);
        tvPhoneNumber.setText(TextUtils.isEmpty(entityUser.getUserPhone()) ? "未绑定" : entityUser.getUserPhone().substring(0, 3) + "****" + entityUser.getUserPhone().substring(7, 11));
        tvEmail.setText(TextUtils.isEmpty(entityUser.getEmail()) ? "未绑定" : entityUser.getEmail());
    }

    @Override
    public void initParam() {
    }

    @Override
    public void initView() {
        tvTitle.setText("安全认证");
    }

    @Override
    public void initOperator() {

    }


    @OnClick({R.id.iv_back, R.id.ll_phone_number, R.id.ll_email})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                onBackPressed();
                break;
            case R.id.ll_phone_number:
                if (TextUtils.isEmpty(entityUser.getUserPhone())) {
                    startActivity(AccountUpdatePhoneActivity.createIntent(context));
                }
                break;
            case R.id.ll_email:
                if (TextUtils.isEmpty(entityUser.getEmail())) {
                    startActivity(AccountEmailBindActivity.createIntent(context));
                }
                break;
        }
    }
}
